//
// Created by Administrator on 2021/11/23.
// May Saint Diana bless you!
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <climits>

using namespace std;

class Solution {
public:
    int countTriples(int n) {
        int ans = 0;
        for (int a = 1; a <= n; ++a) {
            for (int b = a; b <= n; ++b) {
                int c = sqrt(a * a + b * b);
                if (c <= n && c * c == a * a + b * b) {
                    ans += (a == b ? 1 : 2);
                }
            }
        }
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.countTriples(5) << endl;
    cout << solution.countTriples(10) << endl;
    return 0;
}
